package cn.itsource.org.domain;

import cn.itsource.basic.domain.BaseTreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

/**
 * @Description:
 * @Author: ZHl
 * @Date: 2022-09-11 14:26
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "t_department")
@ApiModel(value = "部门实体类")
public class Department extends BaseTreeNode<Department> {

    /**
     * 部门编号
     */
    @ApiModelProperty(value = "部门编号")
    @NotBlank(message = "请输入部门编号")
    @Size(min = 2,max = 5,message = "请输入2-5位数字编号")
    private String sn;

    /**
     * 部门名称
     */
    @ApiModelProperty(value = "部门名称")
    @NotBlank(message = "请输入部门名称")
    private String name;

    /**
     * 部门状态，0正常，1禁用
     */
    @ApiModelProperty(value = "部门状态，0正常，1禁用")
    private Integer state;

    /**
     * 部门管理员，关联Employee表id
     */
    @ApiModelProperty(value = "部门管理员，关联Employee表id")
    private Long managerId;

    /**
     * 父id(上级部门)
     */
    @ApiModelProperty(value = "父id(上级部门)")
    private Long parentId;

    /**
     * 部门级联路径
     */
    @ApiModelProperty(value = "部门级联路径")
    private String dirPath;

    //部门经理
    @Transient
    private Employee manager;

    //上级部门
    @Transient
    private Department parent;

    //父id数组
    @Transient
    private Long[] parentIds;

}
